{% extends "user/common.html" %}

{% block title %}用户借阅{% endblock %}

{% block head %}
    <link rel="stylesheet" type="text/css" href="{{ url_for("static", filename="css/user/borrow.css") }}">
{% endblock %}

{% block body %}
    <header>
        <h1>借阅管理</h1>
    </header>
    <table>
        <thead>
        <tr>
            <th>序号</th>
            <th>书名</th>
            <th>作者</th>
            <th>借阅时间</th>
            <th>归还时间</th>
            <th>状态</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {% for borrow in data.borrows %}
            <tr>
                <td>{{ loop.index }}</td>
                <td>{{ data.book_list[borrow.borrow_id].book_name }}</td>
                <td>{{ data.book_list[borrow.borrow_id].author }}</td>
                <td>{{ borrow.borrow_time }}</td>
                {% if borrow.return_time %}
                    <td>{{ borrow.return_time }}</td>
                {% else %}
                    <td>Null</td>
                {% endif %}

                {% if borrow.return_time %}
                    <td>已归还</td>
                {% else %}
                    <td>未归还</td>
                {% endif %}


                {% if borrow.return_time %}
                    <td>Null</td>
                {% else %}
                    <td><button onclick="window.location.href='{{ url_for('blueprint.return_op', id=borrow.borrow_id) }}'">归还</button></td>
                {% endif %}
            </tr>
        {% endfor %}
        </tbody>
    </table>
{% endblock %}